Skip to content

Fail early when a CKS node's user data is over vm.userdata.max.length - #14781

Open
bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:cks-userdata-size-check
Open

bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:cks-userdata-size-check

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator

Description

This PR makes CKS check each node's user data against vm.userdata.max.length before that node's VM is deployed, and fail with an error that says what's wrong.

New error:

User data for control node of Kubernetes cluster foo is 34120 bytes after base64 encoding, over vm.userdata.max.length (32768). Raise vm.userdata.max.length.

path node type check fires before
create: first control node (after the CNI config is appended) control control VM deploy
create: additional control nodes control that VM's deploy
create: etcd nodes etcd that VM's deploy
create / scale: worker nodes worker first new worker VM deploy
add existing VMs as nodes worker ISO attach, state change, any firewall/PF rule

Other changes:

  • Uses the same limit and length measure as UserDataManagerImpl at deploy time, so the numbers match.
  • logTransitStateAndThrow appends the cause's message when the cause is an InvalidParameterValueException, so the API error shows the reason instead of only Provisioning the control VM failed ....
  • A size failure on an etcd node moves the cluster to Error, instead of leaving it in Starting.
  • Add-node renders the worker config once instead of once per node.

Limits:

  • On create, VMs deployed before the failing node (e.g. etcd nodes, if the control node is the one over the limit) stay until the cluster is deleted, the same as any other create failure.

Fixes: #14780

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

test result
KubernetesClusterActionWorkerTest: under, at and over the limit; cause message appended, not repeated, dropped for other types pass
all KubernetesCluster*Test in cloud-plugin-integrations-kubernetes-service (62 tests) pass

How did you try to break this feature and the system with this change?

  • Checked the deploy-time validation (UserVmManagerImpl.createVirtualMachine → UserDataManagerImpl) to confirm CKS passes the final user data unchanged, so the pre-check can't reject anything deploy would accept.
  • Checked that the worker config doesn't vary per node, so rendering it once on add-node is equivalent.

Each CKS node's rendered cloud-config is checked against
vm.userdata.max.length right after base64 encoding, before the VM is
deployed.

| path | node type checked | fires before |
|---|---|---|
| create: first control node (after CNI config is appended) | control | control VM deploy |
| create: additional control nodes | control | that VM's deploy |
| create: etcd nodes | etcd | that VM's deploy |
| create / scale: worker nodes | worker | first new worker VM deploy |
| add existing VMs as nodes | worker | ISO attach, state change, any rule |

- Same limit and length measure as UserDataManagerImpl uses at deploy
  time, so the numbers match.
- The error names the node type, the cluster, the size and the limit.
- logTransitStateAndThrow appends the cause's message when the cause
  is an InvalidParameterValueException, so the API error shows it
  instead of only "Provisioning the control VM failed ...".
- A size failure on an etcd node moves the cluster to Error like the
  other node types, instead of leaving it in Starting.
- Add-node renders the worker config once instead of once per node.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.32%. Comparing base (b56bbc2) to head (6c3a401).

Files with missing lines Patch % Lines
...ster/actionworkers/KubernetesClusterAddWorker.java 0.00% 16 Missing ⚠️
...er/actionworkers/KubernetesClusterStartWorker.java 0.00% 10 Missing ⚠️
...r/actionworkers/KubernetesClusterActionWorker.java 87.50% 0 Missing and 1 partial ⚠️
...KubernetesClusterResourceModifierActionWorker.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #14781      +/-   ##
============================================
- Coverage     18.32%   18.32%   -0.01%     
- Complexity    16644    16650       +6     
============================================
  Files          5939     5939              
  Lines        537787   537807      +20     
  Branches      65932    65934       +2     
============================================
- Hits          98544    98535       -9     
- Misses       428033   428059      +26     
- Partials      11210    11213       +3     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.41% <20.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant